/**
 * 
 */
package com.huxi.lang.local.support;

import java.util.Objects;
import java.util.TimeZone;

import org.apache.commons.lang3.time.FastDateFormat;

import com.huxi.lang.annotation.ThreadSecured;

/**
 * 日期与时间本地化接口安全实现（线程安全）
 * 
 * @author jian.wu
 * @since 1.0
 * @version 1.0
 */
@ThreadSecured
public class SafeDateContext extends AbstractDateContext {

	private FastDateFormat dateFormat;
	private FastDateFormat timestampFormat;

	public SafeDateContext(TimeZone timeZone, FastDateFormat dateFormat, FastDateFormat timestampFormat) {
		super(timeZone);
		this.dateFormat = Objects.requireNonNull(dateFormat);
		this.timestampFormat = Objects.requireNonNull(timestampFormat);
	}

	@Override
	public FastDateFormat createDateFormat(String pattern) {
		return FastDateFormat.getInstance(pattern, getTimeZone());
	}

	@Override
	public FastDateFormat getDateFormat() {
		return dateFormat;
	}

	@Override
	public FastDateFormat getTimestampFormat() {
		return timestampFormat;
	}

}
